<!DOCTYPE html>
<html lang="en"><head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Begin Jekyll SEO tag v2.8.0 -->
<title>X0002: GtkD Linux Development Environment | gtkDcoding</title>
<meta name="generator" content="Jekyll v4.3.4" />
<meta property="og:title" content="X0002: GtkD Linux Development Environment" />
<meta name="author" content="Ron Tarrant" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="How to install and use a GTK and D-language build environment on Linux Mint." />
<meta property="og:description" content="How to install and use a GTK and D-language build environment on Linux Mint." />
<link rel="canonical" href="http://localhost:4000/posts/x0002-gtkd-in-a-linux-environment.html" />
<meta property="og:url" content="http://localhost:4000/posts/x0002-gtkd-in-a-linux-environment.html" />
<meta property="og:site_name" content="gtkDcoding" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2019-03-31T00:00:00-04:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="X0002: GtkD Linux Development Environment" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Ron Tarrant"},"dateModified":"2019-03-31T00:00:00-04:00","datePublished":"2019-03-31T00:00:00-04:00","description":"How to install and use a GTK and D-language build environment on Linux Mint.","headline":"X0002: GtkD Linux Development Environment","mainEntityOfPage":{"@type":"WebPage","@id":"http://localhost:4000/posts/x0002-gtkd-in-a-linux-environment.html"},"url":"http://localhost:4000/posts/x0002-gtkd-in-a-linux-environment.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="../assets/main.css">
  <link rel="stylesheet" href="../css/style.css" /><link type="application/atom+xml" rel="alternate" href="http://localhost:4000/feed.xml" title="gtkDcoding" /></head>
<body><header class="site-header" role="banner">

  <div class="wrapper"><a class="site-title" rel="author" href="../">gtkDcoding</a><nav class="site-nav">
        <input type="checkbox" id="nav-trigger" class="nav-trigger" />
        <label for="nav-trigger">
          <span class="menu-icon">
            <svg viewBox="0 0 18 15" width="18px" height="15px">
              <path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
            </svg>
          </span>
        </label>

        <div class="trigger"><a class="page-link" href="../about.html">About</a><a class="page-link" href="../index-reverse.html">Posts in Date Order</a><a class="page-link" href="../topics.html">Blog Posts by Topic</a></div>
      </nav></div>
</header>
<main class="page-content" aria-label="Content">
      <div class="wrapper">
        <article class="post h-entry" itemscope itemtype="http://schema.org/BlogPosting">
	<header class="post-header">
		<link rel="stylesheet" href="../css/font_size.css" />
		<link rel="stylesheet" href="../css/figure.css" />
		<link rel="stylesheet" href="../css/topics/linux.css" />  <!-- sub in the tag/topic -->
		<link rel="stylesheet" href="../css/modal.css" />
		<link rel="stylesheet" href="../css/post.css" />
		<link rel="stylesheet" href="../css/mascot_effects.css" />

		
		
		<p class="post-meta">
		<time class="dt-published" datetime="2019-03-31T00:00:00-04:00" itemprop="datePublished">Sunday, March 31, 2019
		</time>• by <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span class="p-author h-card" itemprop="name">Ron Tarrant</span></span></p>
	</header>

	<div class="post-content e-content" itemprop="articleBody">
		<div class="skew-line"></div>
		<h2 id="x0002-gtkd-linux-development-environment">X0002: GtkD Linux Development Environment</h2>

<p>Okay, hold onto your hat, because we’re gonna install and test a D language development environment on Linux.</p>

<p>Disclaimer:
I’ve been away from Linux for a donkey’s age, so I’m only covering what I know so far, the installation procedure on Linux Mint 19.1, the distro I use here. I assume this will also work if you use Ubuntu or Debian, the parent and grandparent distros for Mint, but don’t quote me.</p>

<p>However, I have it on a good authority (from Mike Wey, the sole remaining member of the GtkD dev team and keeper of the GtkD forum) that using <a href="https://dlang.org/install.html">the install.sh script</a> will work for most, if not all, other distros. And for installing GtkD, you can follow the guidelines under <em>Installation</em> <a href="https://github.com/gtkd-developers/GtkD/wiki">at the bottom of this page</a>.</p>

<p>Mike also suggested that if your distro includes the D Language and/or GtkD, it’s best to use your native package manager for installation. And he kindly agreed to vet this post for technical accuracy, for which I thank him.</p>

<p>Anyway, let’s get on with it, shall we?</p>

<h3 id="installation-on-linux-an-apt-approach">Installation On Linux (an Apt Approach)</h3>

<p>Note: You can just copy and paste these commands into a shell to avoid mistyping stuff, or go it the hard way and practice your touchtyping skills. Up to you.</p>

<p>First, let’s establish access to the repository:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo wget https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
</code></pre></div></div>

<p>Second, set things up so apt-get won’t complain about repositories that may not adhere 100% to its security protocols:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get update --allow-insecure-repositories &amp;&amp; sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring &amp;&amp; sudo apt-get update
</code></pre></div></div>

<p>Third, we do the actual installation (this does everything, the D language, GtkD wrappers and libraries, docs, the works):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install dmd-compiler dmd-doc libgtkd3-dev libgtkd3-doc
</code></pre></div></div>

<p>And one more command to install dmd-tools (which installs some coolness we’ll talk about some day):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install dmd-tools
</code></pre></div></div>

<p>You should now have a working development environment for D and GtkD.</p>

<h3 id="one-way-to-build">One Way to Build</h3>

<p>We’re almost ready to compile some code, but first we need to find the wrappers and the static and/or shared gtk libraries. Open a shell and issue this command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pkg-config --cflags --libs gtkd-3
</code></pre></div></div>

<p>What pkg-config does is query the list of installed software and find out which directories these things got stuffed into. But it does more than that. By including the <code class="language-plaintext highlighter-rouge">--cflags</code> directive, we get compiler flags we can copy and hand over to dmd.</p>

<p>So, navigate to a directory containing one of the GtkD code files and type this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dmd -de -w -m64  -I/usr/include/dmd/gtkd3 -L-L/usr/lib/x86_64-linux-gnu -L-L/usr/lib/i386-linux-gnu -L-l:libgtkd-3.so -L-l:libdl.so.2 -L--no-warn-search-mismatch -defaultlib=libphobos2.so &lt;code-filename&gt;.d -of&lt;executable-filename&gt;
</code></pre></div></div>

<p>Well, that was fun, although it’s a bit much to type every time. Let’s save some wear and tear on our fingers by finding…</p>

<h3 id="another-way-to-build">Another Way to Build</h3>

<p>It turns out that if we surround that pkg-config command with back-ticks, we can use its output as arguments to dmd like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dmd -de -w -m64  `pkg-config --cflags --libs gtkd-3` &lt;code-filename&gt;.d -of&lt;executable-filename&gt;
</code></pre></div></div>

<p>Better, but this being Linux, we can pull a Bash trick to make it even easier.</p>

<h3 id="alias-away-the-typing">Alias Away the Typing</h3>

<p>A default installation of <em>Linux Mint 19.1 xfce</em> doesn’t have a <code class="language-plaintext highlighter-rouge">.bash_aliases</code> file, but creating one is not big deal:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>touch ~/.bash_aliases
</code></pre></div></div>

<p>Default permissions will work, so no need to mess with <code class="language-plaintext highlighter-rouge">chmod</code>. Then all you need to do is fire up an editor and add this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># D compiler command line alias for building with shared libraries
alias dbuild="dmd -de -w -m64 `pkg-config --cflags --libs gtkd-3`"

# D compiler command alias for building with static libraries
alias dbuild_static="dmd `pkg-config --cflags --libs gtkd-3-static`"
</code></pre></div></div>

<p>After saving <code class="language-plaintext highlighter-rouge">.bash_aliases</code>, open a new shell (any shell opened before these aliases are added won’t recognize these aliases) and type either:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dbuild &lt;code_filename&gt;.d
</code></pre></div></div>

<p>or</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dbuild_static &lt;code_filename&gt;.d
</code></pre></div></div>

<p>And if you want the executable filename to be different from the code filename, just add this to the end of either of the above:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-of&lt;executable_filename&gt;
</code></pre></div></div>

<h3 id="conclusion">Conclusion</h3>

<p>And there you have it, installation instructions for <em>Linux Mint</em> plus two ways to build and link D source on Linux without typing yourself into an early grave.</p>

<p>I hope you enjoyed this Blog eXtra. I’ll continue to spring these on you from time to time, covering such subjects as:</p>

<ul>
  <li>using dub as a build tool,</li>
  <li>installing a GtkD development environment on FreeBSD, and</li>
  <li>various shortcuts I discover as things progress.</li>
</ul>

<p>Until next time…</p>

<div class="blog-nav">
	<div style="float: left;">
		<a href="./0022-grids.html">Previous: Grids</a>
	</div>
	<div style="float: right;">
		<a href="./0023-radio-and-color-buttons.html">Next: Radio and Color Buttons</a>
	</div>
</div>
<p>
	<h3></h3>
<div class="inpage-frame">
	<a href="https://github.com/sponsors/rontarrant">
		<BR>
		<BR>
		<B>Is this article useful? Educational? Entertaining, perhaps?</B>
		<BR>
		<figure class="left">
			<img src="../images/favorite_32.png" alt="Sponsorship heart" style="width: 32px; height: 32px;">
		</figure>
		You're free to accept or decline this invitation to become our newest sponsor.
	</a>
</div>
	<h4 class="comment-blurb"><B>Comments? Questions? Observations?</B></h4>
	<p>
		Did we miss a tidbit of information that would make this post even more informative? Let's talk about it in the comments.
	</p>
	<script src="https://utteranc.es/client.js"
		repo="rontarrant"
		issue-term="pathname"
		theme="github-light"
		crossorigin="anonymous"
		async>
	</script>
	<ul>
		<li> come on over to the <a href="https://forum.dlang.org/">D Language Forum</a> and look for one of the <i>gtkDcoding</i> announcement posts, </li>
		<li> drop by <a href="https://forum.gtkd.org/">the <i>GtkD Forum</i></a>,</li>
		<li> follow the link below to email me, or</li>
		<li> go to the	<a href="https://www.facebook.com">gtkDcoding Facebook page.</a></li>
	</ul>
</p>
<p> You can also subscribe <a href="/feed.xml">via RSS</a> so you won't miss anything. Thank you very much for dropping by.</p>
<p>&copy; Copyright 2025 Ron Tarrant </p>
</div>

	<a class="u-url" href="./x0002-gtkd-in-a-linux-environment.html" hidden></a>
</article>

      </div>
    </main><footer class="site-footer h-card">
  <data class="u-url" href="/"></data>

  <div class="wrapper">

    <h2 class="footer-heading">gtkDcoding</h2>

    <div class="footer-col-wrapper">
      <div class="footer-col footer-col-1">
        <ul class="contact-list">
          <li class="p-name">Ron Tarrant</li><li><a class="u-email" href="mailto:gtkDcoding@gmail.com">gtkDcoding@gmail.com</a></li></ul>
      </div>

      <div class="footer-col footer-col-2"><ul class="social-media-list"><li><a href="https://github.com/rontarrant"><svg class="svg-icon"><use xlink:href="../assets/minima-social-icons.svg#github"></use></svg> <span class="username">rontarrant</span></a></li></ul>
</div>

      <div class="footer-col footer-col-3">
        <p>Simple examples of how to use GtkD to build GUI applications.</p>
      </div>
    </div>

  </div>

</footer>
</body>

</html>
